const TokenKey = 'App-Token'

export function getToken() {
	return uni.getStorageSync(TokenKey)
}

export function setToken(token) {
	return uni.setStorageSync(TokenKey, token)
}

export function removeToken() {
	return uni.removeStorageSync(TokenKey)
}

export function go(url) {
	if (getToken()) {
		uni.navigateTo({
			url: "/pages/" + url
		})
	} else {
		uni.navigateTo({
			url: "/pages/login"
		})
	}
}

export function to(url) {
	uni.navigateTo({
		url: "/pages/" + url
	})
}

export function goReport(id, orderNo = false) {
	let report = ['', 'bdp', 'bd', 'com', 'mar', 'jud', 'imm', 'edu']
	let url = "/pages/" + report[id]
	if (orderNo) {
		url += ('?orderNo=' + orderNo)
	}
	uni.navigateTo({
		url: url
	})
}